package com.dxysun.jvm;

public class SafepointTest
{
    static double sum = 0;

    public static void foo()
    {
        long start = System.currentTimeMillis();
        System.out.println("foo start:" + start);
        for (int i = 0; i < 0x77777777; i++) {
            sum += Math.sqrt(i);
        }
        long cost = System.currentTimeMillis() - start;
        System.out.println("foo cost:" + cost);

    }

    public static void bar()
    {
        long start = System.currentTimeMillis();
        System.out.println("bar start:" + start);
        for (int i = 0; i < 50_000_000; i++) {
            new Object().hashCode();
        }
        long cost = System.currentTimeMillis() - start;
        System.out.println("bar cost:" + cost);
    }

    public static void main(String[] args)
    {

        new Thread(SafepointTest::foo).start();
        new Thread(SafepointTest::bar).start();
    }
}
